<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
class User_model extends MY_model {
	public function __construct() {
		parent::__construct ( 'user' );
	}
	/**
	 * 创建数据表
	 */
	public function create() {
		$this->drop ();
		$sql = "CREATE TABLE `user` (
				  `uid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID',
				  `email` varchar(200) NOT NULL COMMENT 'email',
				  `logo` varchar(100) NOT NULL COMMENT '头像',
				  `username` varchar(20) NOT NULL COMMENT '用户名',
				  `password` varchar(255) NOT NULL COMMENT '密码',
				  `createtime` int(10) unsigned NOT NULL COMMENT '创建时间',
				  `telephone` char(11) NOT NULL COMMENT '电话号码',
				  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '用户状态（0：冻结；1：未激活；2：激活）',
				  PRIMARY KEY (`uid`,`email`,`username`)
				) ENGINE=InnoDB AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8 COMMENT='用户表';";
		$re = $this->db->simple_query ( $sql );
		return $re;
	}
	/**
	 * 删除数据表
	 */
	public function drop() {
		$sql = 'DROP TABLE IF EXISTS `user`;';
		$re = $this->db->simple_query ( $sql );
		return $re;
	}
}